package g4p.styledtext;

import g4p_controls.G4P;
import g4p_controls.GLabel;
import g4p_controls.StyledString;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import processing.core.PApplet;
import processing.core.PGraphicsJava2D;

public class FontSize extends PApplet {

	StyledString s;
	StyledString[] ss;
	GLabel lblText;
	PGraphicsJava2D buffer;
	
	public void setup(){
		size(300, 300, JAVA2D);
		background(255);
		
		buffer = (PGraphicsJava2D) createGraphics((int)width, (int)height, PApplet.JAVA2D);
		buffer.g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
				RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
		
		buffer.beginDraw();
		buffer.background(color(255,0));
		Graphics2D g2d = (Graphics2D) buffer.g2;
		g2d.setFont(new Font("DIALOG", Font.BOLD, 24));

		ss = new StyledString[4];
		s = new StyledString("4");
		s.addAttribute(G4P.SIZE, 24);
		ss[0] = s;
		s = new StyledString("8");
		s.addAttribute(G4P.SIZE, 12);
		ss[1] = s;
		s = new StyledString("4");
		s.addAttribute(G4P.SIZE, 12);
		ss[2] = s;
		s = new StyledString("8");
		s.addAttribute(G4P.SIZE, 16);
		ss[3] = s;
		
		buffer.stroke(255,0,0);
		buffer.line(0,40,buffer.width,	40);
		
		g2d.setColor(Color.blue);
		
		ss[0].getLines(g2d).getFirst().layout.draw(g2d, 20, 40);
		ss[1].getLines(g2d).getFirst().layout.draw(g2d, 40, 40);
		ss[2].getLines(g2d).getFirst().layout.draw(g2d, 60, 40);
		ss[3].getLines(g2d).getFirst().layout.draw(g2d, 80, 40);
		buffer.endDraw();
		image(buffer,0,0);
	}
	

//	public void draw(){
//		background(255);
//		fill(0);
//	}

}
